package pers.corvey.studyjava;

import java.io.File;

public final class MyConstant {

    public static final String CLASS_STATIC_PATH = Thread.currentThread().getContextClassLoader()
            .getResource("").getPath() + "/static/";
    
    public static final String BACKUP_STATIC_PATH = CLASS_STATIC_PATH.split("target")[0] 
            + "/src/main/resources/static/";
    
    public static final String DOC_FILE_PATH = "/doc/";
    
    public static final String FILE_PATH = "/file/";
    
    public static final int COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
    
    static {
        createFilePath(DOC_FILE_PATH);
        createFilePath(FILE_PATH);
    }
    
    private static void createFilePath(String dirPath) {
        File file = new File(CLASS_STATIC_PATH, dirPath);
        if (!file.exists()) file.mkdir();
        file = new File(BACKUP_STATIC_PATH, dirPath);
        if (!file.exists()) file.mkdir();
    }
}
